< previous page page_36 next page >

Page 36
on their computers. Sometimes the font selected by the system will make your controls look strange or line up incorrectly.
One way to avoid this problem is to use a font that you are reasonably sure will be available on the system running the program. If you pick one of the standard fonts that is shipped with Windows, you will be fairly safe. Some of the most common fonts are Arial, Courier New, MS Sans Serif, and Times New Roman.
Font Size Property
A Font object's Size property determines the size of the text. A font's size is measured in printer's points with 72 points to an inch. However, just because you ask for a font in a certain size does not mean the system will give it to you. The system can provide different fonts only in certain fixed sizes. When you set a Font object's Size property, your program gets the fixed size closest to the one you specified.
Some fonts, such as TrueType fonts, are designed to be scaled. They contain mathematical instructions for drawing characters at a wide variety of different sizes. The system can scale these fonts easily so that it can produce them at many different sizes. Arial, Courier New, and Times New Roman are TrueType fonts.
Other fonts are provided in bitmap formats to be displayed only at specific sizes. If you request one of these fonts in a nonstandard size, the system may scale the font. These fonts tend to look somewhat rough when they are displayed at nonstandard sizes. MS Sans Serif is one such font.
Even if the font you are using is scalable, you may not get exactly the size you request. The system usually gives you a font that is within one printer's point of the size you want. Keep in mind that a point is only 1/72 of an inch. If you ask for 73 point and get 72.75 point instead, the system has adjusted your font by only 1/4 of a point, or about 0.003 inches.
This resizing of fonts can be a bigger problem if you are not careful when you change typefaces and sizes. Suppose you have a label in 18 point MS Sans Serif and you want it in 21 point Arial. You could execute the following code:
e10a6a0a59f035e870d90cca05b85fce.gif
Label1.Font.Size = 21
Label1.Font.Name = "Arial"
When Visual Basic executes the first command, it tries to make the label use 21-point MS Sans Serif. Unfortunately, MS Sans Serif does not have a 21-point size. The nearest available size is 19.5 point, so Visual Basic sets the font size to 19.5. Now when you set the font name to Arial, the label displays in 19.5-point Arial.
This problem does not occur if you execute the two statements in reverse order.
e10a6a0a59f035e870d90cca05b85fce.gif
Label1.Font.Name = "Arial"
Label1.Font.Size = 21

 
< previous page page_36 next page >